# -*- coding:utf-8 -*-
# Author: Bernard
# Date: 2021-7-14

class stu():
    def __init__(self, a):
        self.idx = int(a[0])
        self.name = a[1]
        self.score = int(a[2])

    def __lt__(self, other):
        return self.score < other.score

    def __format__(self, format_spec: str) -> str:
        return str(self.idx)+'\t'+self.name+'\t'+str(self.score)


arr = []

n = int(input())
for _ in range(n):
    arr.append(stu(list(input().split())))

arr.sort(reverse=True)

print('学号\t\t姓名\t成绩\t名次')
order = 1
for i in arr:
    print(format(i)+'\t'+str(order))
    order += 1